<!--
 * @Description: 工程管理
 * @Author: wangwangwang
 * @Date: 2020-08-17 15:52:03
 * @LastEditors  : yangxr
 * @LastEditTime : 2021-12-27 17:29:57
-->
<template>
  <div class="pages_content table">
    <el-container>
      <el-header>
        <breaDcrumb />
      </el-header>
      <el-main>
        <div class="header_right" @click="showCardNav = !showCardNav">
          <div class="title">搜索</div>
          <div>
            <div
              :class="{
                arrowTransform: !showCardNav,
                arrowTransformReturn: showCardNav,
              }"
            >
              <i style="margin-right: 5px" class="el-icon-arrow-down"></i>
            </div>
          </div>
        </div>
        <div v-show="showCardNav" class="hr"></div>
        <el-collapse-transition>
          <div v-show="showCardNav">
            <div class="search">
              <span style="display: inline-block; margin-bottom: 10px">
                <span style="margin-right: 12px">工程名称</span>
                <el-input
                  v-model="tableParam.name"
                  style="width: 200px"
                  clearable
                  placeholder="请输入"
                  @keyup.enter.native="gettableData()"
                />
              </span>
              <!-- <span style="margin-left: 24px;">
                <span style="margin-right: 12px;">施工单位</span>
                <el-input v-model="tableParam.roadwork" style="width: 20%;max-width: 200px;" clearable placeholder="请输入" @keyup.enter.native="gettableData()" />
              </span> -->
              <el-button
                icon="el-icon-search"
                size="medium"
                class="bottom_all but1"
                @click="(tableParam.page = 1), gettableData()"
                >查 询</el-button
              >
              <el-button
                size="medium"
                class="bottom_all_two"
                style="margin-left: 12px"
                @click="init()"
                >重 置</el-button
              >
              <el-button
                size="medium"
                class="bottom_all_two"
                style="margin-left: 12px"
                @click="tableParamType = true"
                >高级搜索</el-button
              >
            </div>
          </div>
        </el-collapse-transition>
        <div class="hr"></div>
        <div class="card">
          <div class="card_nav">
            <div>
              <el-button
                v-if="
                  ButtonList.findIndex(
                    (res) => res.buttonValue == 'SHENGCHANCHUDENGJIGC'
                  ) !== -1
                "
                size="small"
                class="bottom_all"
                style="margin-left: 0"
                @click="fromDate2TypeTrue()"
              >
                <i
                  class="icon iconfont iconicon_button_add"
                  style="font-size: 12px"
                ></i>
                生产处登记工程
              </el-button>
              <el-button
                v-if="
                  ButtonList.findIndex(
                    (res) => res.buttonValue == 'XIAOSHOUCHUDENGJIGC'
                  ) !== -1
                "
                size="small"
                class="bottom_all"
                @click="changeVisited('', true, false)"
              >
                <i
                  class="icon iconfont iconicon_button_add"
                  style="font-size: 12px"
                ></i>
                销售处登记工程
              </el-button>
            </div>
          </div>
          <div v-loading="tableLoading" class="card_info" :style="style">
            <el-table
              :header-cell-style="{ background: '#f3f6f9' }"
              :cell-style="{ borderRight: 'none' }"
              border
              stripe
              style="width: 100%"
              :data="tableData"
              tooltip-effect="dark"
              @selection-change="handleSelectionChange"
            >
              <el-table-column
                align="center"
                prop="code"
                label="工程编号"
                min-width="140"
              ></el-table-column>
              <el-table-column align="center" label="工程名称" min-width="140">
                <template slot-scope="scope">
                  <span
                    v-if="scope.row.dataType == 2"
                    style="color: #008200; cursor: pointer"
                    @click="sumbit2Modify(scope.row, true)"
                    >{{ scope.row.name }}</span
                  >
                  <span
                    v-else
                    style="color: #008200; cursor: pointer"
                    @click="datails(scope.row)"
                    >{{ scope.row.name }}</span
                  >
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                prop="businesName"
                label="业务类型"
                min-width="140"
              ></el-table-column>
              <!-- <el-table-column align="center" prop="roadwork" label="施工单位" min-width="140"></el-table-column>
              <el-table-column align="center" prop="roadworklInkman" label="联系人" min-width="140"></el-table-column>
              <el-table-column align="center" prop="roadworkPhone" label="联系电话" min-width="140"></el-table-column> -->
              <el-table-column
                align="center"
                prop="createTime"
                label="登记时间"
                min-width="200"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="principal"
                label="负责人"
                min-width="140"
              ></el-table-column>
              <el-table-column align="center" label="执行阶段" width="130">
                <template slot-scope="scope">
                  <span v-if="scope.row.dataType == 2"></span>
                  <span v-else>
                    <el-select
                      v-model="scope.row.executePhase"
                      :disabled="
                        scope.row.executePhase === 4 &&
                        scope.row.contractStatus != 0
                      "
                      style="width: 100%"
                      placeholder="请选择"
                      @change="changstatus(scope.row)"
                    >
                      <el-option
                        v-for="(item, index) in executePhaselist"
                        :key="index"
                        :label="item.itemName"
                        :value="item.id"
                      ></el-option>
                    </el-select>
                  </span>
                </template>
              </el-table-column>
              <el-table-column align="center" label="状态" width="130">
                <template slot-scope="scope">
                  <span v-if="scope.row.dataType == 2">生产处登记</span>
                  <span v-else>
                    <span v-if="scope.row.executePhase == 1">
                      {{
                        ["待登记", "待审核", "审核中", "未通过", "已通过"][
                          scope.row.entrustStatus * 1
                        ]
                      }}
                    </span>
                    <span v-if="scope.row.executePhase == 2">
                      {{
                        ["待登记", "待审核", "评估中", "未通过", "已通过"][
                          scope.row.assessStatus * 1
                        ]
                      }}
                    </span>
                    <span v-if="scope.row.executePhase == 3">
                      {{
                        ["", "投标中", "已中标", "未中标"][
                          scope.row.bidStatus * 1
                        ]
                      }}
                    </span>
                    <span v-if="scope.row.executePhase == 4">
                      {{
                        ["待登记", "待审核", "审核中", "未通过", "已通过"][
                          scope.row.contractStatus * 1
                        ]
                      }}
                    </span>
                  </span>
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="操作"
                width="100"
                fixed="right"
              >
                <template slot-scope="scope">
                  <el-dropdown :hide-on-click="false" trigger="click">
                    <el-button size="mini" class="bottom_one">更多</el-button>
                    <el-dropdown-menu slot="dropdown">
                      <el-dropdown-item
                        v-if="
                          ButtonList.some(
                            (res) => res.buttonValue == 'YIJIAOGC'
                          )
                        "
                      >
                        <el-button
                          style="margin: 5px 0"
                          class="bottom_one"
                          size="mini"
                          @click="hanldeSure(scope.row)"
                        >
                          移交
                        </el-button>
                      </el-dropdown-item>
                      <el-dropdown-item
                        v-if="
                          scope.row.dataType == 1 &&
                          ButtonList.some((res) => res.buttonValue == 'XIUGAI')
                        "
                      >
                        <el-button
                          style="margin: 5px 0"
                          class="bottom_one"
                          :disabled="
                            scope.row.executePhase === 4 &&
                            scope.row.contractStatus != 0
                          "
                          size="mini"
                          @click="changeVisited(scope.row, true)"
                        >
                          修改
                        </el-button>
                      </el-dropdown-item>
                      <el-dropdown-item
                        v-if="
                          scope.row.dataType == 2 &&
                          ButtonList.some((res) => res.buttonValue == 'XIUGAI')
                        "
                      >
                        <el-button
                          style="margin: 5px 0"
                          class="bottom_one"
                          :disabled="
                            scope.row.executePhase === 4 &&
                            scope.row.contractStatus != 0
                          "
                          size="mini"
                          @click="sumbit2Modify(scope.row)"
                        >
                          修改
                        </el-button>
                      </el-dropdown-item>
                      <el-dropdown-item
                        v-if="
                          ButtonList.some((res) => res.buttonValue == 'SHANCHU')
                        "
                      >
                        <el-button
                          style="margin: 5px 0"
                          class="bottom_one"
                          :disabled="
                            (scope.row.executePhase === 1 ||
                              scope.row.executePhase === 4) &&
                            (scope.row.entrustStatus === 4 ||
                              scope.row.contractStatus === 4)
                          "
                          size="mini"
                          @click="deleteDisclose(scope.row)"
                        >
                          删除
                        </el-button>
                      </el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </el-main>
      <div class="card_bottom">
        <div class="card_bottom_left">
          <div class="top_page_totle">总共{{ total }}条</div>
          <el-pagination
            :current-page.sync="tableParam.page"
            :page-size="tableParam.pageSize"
            :page-sizes="[10, 20, 30, 40, 50, 100, 200, 500, 1000]"
            layout="prev,pager,sizes,next,jumper"
            :total="total"
            @size-change="sizeChange"
            @current-change="gettableData()"
          ></el-pagination>
        </div>
        <div>
          <el-button
            size="mini"
            icon="el-icon-refresh-right"
            class="bottom_all_two"
            @click="gettableData"
            >刷新</el-button
          >
        </div>
      </div>
    </el-container>
    <!-- 添加工程 -->
    <regproject
      ref="cz"
      :status="visited"
      :sendData="visitedata"
      type="0"
      :executePhaseType="executePhaseType"
      @close="close"
      @sumbit="sumbit"
    ></regproject>
    <!-- 查看详情 -->
    <el-dialog
      v-dialogDrag
      :visible.sync="show"
      width="1085px"
      :close-on-click-modal="false"
    >
      <span slot="title" class="dialog-title">工程信息</span>
      <div class="dialoginfo show">
        <el-form :inline="true" label-width="110px" disabled>
          <div class="form-title">工程基本信息</div>
          <el-form-item prop="name">
            <span slot="label" style="color: #ff0000">工程名称</span>
            <el-input
              v-model="fromDate.name"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item prop="place">
            <span slot="label" style="color: #ff0000">地理位置</span>
            <el-input
              v-model="fromDate.place"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item prop="expectedAmount" label-width="160px">
            <span slot="label" style="color: #ff0000">预估用砼量（方）</span>
            <el-input
              v-model="fromDate.expectedAmount"
              style="width: 176px"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item prop="roadworkId">
            <span slot="label" style="color: #ff0000">合同单位</span>
            <el-select
              v-model="fromDate.roadworkId"
              placeholder="请选择"
              filterable
              clearable
            >
              <el-option
                v-for="(item, index) in roadworkIdList"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="businessTypeId">
            <span slot="label" style="color: #ff0000">业务类型</span>
            <el-select v-model="fromDate.businessTypeId" placeholder="请选择">
              <el-option label="市场扩展" value="1"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="executePhase">
            <span slot="label" style="color: #ff0000">执行阶段</span>
            <el-select v-model="fromDate.executePhase" placeholder="请选择">
              <el-option label="委托交底" :value="1"></el-option>
              <el-option label="评估" :value="2"></el-option>
              <el-option label="投标" :value="3"></el-option>
              <el-option label="合同交底" :value="4"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <span slot="label">工程性质</span>
            <el-select
              ref="typeId"
              v-model="fromDate.typeId"
              placeholder="请选择"
              @change="
                $nextTick(() => {
                  fromDate.type = $refs.typeId.selectedLabel;
                })
              "
            >
              <el-option
                v-for="(item, index) in typeIdList"
                :key="index"
                :label="item.itemName"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="rateOfProgressId">
            <span slot="label">项目进度</span>
            <el-select
              ref="rateOfProgressId"
              v-model="fromDate.rateOfProgressId"
              placeholder="请选择"
              @change="
                $nextTick(() => {
                  fromDate.rateOfProgress =
                    $refs.rateOfProgressId.selectedLabel;
                })
              "
            >
              <el-option
                v-for="(item, index) in rateOfProgressIdList"
                :key="index"
                :label="item.itemName"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <span slot="label">起供时间</span>
            <el-date-picker
              v-model="fromDate.startTime"
              type="datetime"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd HH:mm:ss"
            ></el-date-picker>
          </el-form-item>
          <div>
            <el-form-item>
              <span slot="label">施工单位</span>
              <el-input
                v-model="fromDate.contractSigningUnit"
                placeholder="请输入"
                clearable
              ></el-input>
            </el-form-item>
            <el-form-item prop="roadworklInkman">
              <span slot="label">联系人</span>
              <el-input
                v-model="fromDate.roadworklInkman"
                placeholder="请输入"
                clearable
              ></el-input>
            </el-form-item>
            <el-form-item prop="roadworkPhone">
              <span slot="label">电话</span>
              <el-input
                v-model="fromDate.roadworkPhone"
                placeholder="请输入"
                clearable
                oninput="if(value.length > 11)value = value.slice(0, 11)"
              ></el-input>
            </el-form-item>
            <el-form-item>
              <span slot="label">建设单位</span>
              <el-input
                v-model="fromDate.constructionUnit"
                placeholder="请输入"
                clearable
              ></el-input>
            </el-form-item>
            <el-form-item>
              <span slot="label">联系人</span>
              <el-input
                v-model="fromDate.cuLinkman"
                placeholder="请输入"
                clearable
              ></el-input>
            </el-form-item>
            <el-form-item>
              <span slot="label">电话</span>
              <el-input
                v-model="fromDate.cuPhone"
                placeholder="请输入"
                clearable
                oninput="if(value.length > 11)value = value.slice(0, 11)"
              ></el-input>
            </el-form-item>
          </div>
          <div>
            <el-form-item>
              <span slot="label">机会类型</span>
              <el-select
                ref="clientTypeId"
                v-model="fromDate.clientTypeId"
                placeholder="请选择"
                @change="
                  $nextTick(() => {
                    fromDate.clientType = $refs.clientTypeId.selectedLabel;
                  })
                "
              >
                <el-option
                  v-for="(item, index) in clientTypeIdList"
                  :key="index"
                  :label="item.itemName"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <span slot="label">行政区</span>
              <el-cascader
                v-model="fromDate.administrativeDistricts0"
                style="width: 227px"
                :options="treeData"
              ></el-cascader>
            </el-form-item>
          </div>
          <el-form-item>
            <span slot="label">管柱（米）</span>
            <el-input
              v-model="fromDate.tubularColumn"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item>
            <span slot="label">装配式</span>
            <el-input
              v-model="fromDate.fabricated"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <div>
            <el-form-item
              v-if="UserInfo.adminStatus == 1"
              prop="createUserId"
              :rules="[
                { required: true, message: '请选择负责人', trigger: 'change' },
              ]"
              class="FZYdanWei"
            >
              <span slot="label">负责人</span>
              <el-cascader
                ref="getCheckedNodes"
                v-model="fromDate.createUserId"
                style="width: 227px"
                :options="principalarr"
                :show-all-levels="false"
                :props="{ value: 'id', label: 'name' }"
                :placeholder="createUserName"
              ></el-cascader>
            </el-form-item>
          </div>
          <el-form-item>
            <span slot="label">备注</span>
            <el-input
              v-model="fromDate.remark"
              style="width: 920px"
              type="textarea"
              :rows="5"
              resize="none"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="show = false"
          >取 消</el-button
        >
      </span>
    </el-dialog>
    <!-- 移交 -->
    <personProject
      :visible="personVisible"
      @closeModel="closeModel"
      @getPerson="getPerson"
    />
    <!-- 高级搜索 -->
    <el-dialog
      v-dialogDrag
      :visible.sync="tableParamType"
      width="650px"
      :close-on-click-modal="false"
    >
      <span slot="title" class="dialog-title">高级搜索</span>
      <div class="dialoginfo">
        <el-form
          ref="reftableParam"
          :inline="true"
          :model="tableParam"
          label-width="110px"
        >
          <el-form-item>
            <span slot="label">联系人</span>
            <el-input
              v-model="tableParam.roadworklInkman"
              tplaceholder="请输入"
              clearable
              style="width: 400px"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <span slot="label">登记时间</span>
            <el-date-picker
              v-model="startTimDateEndTimDate"
              type="datetimerange"
              value-format="yyyy-MM-dd HH:mm:ss"
              unlink-panels
              start-placeholder="开始时间"
              end-placeholder="结束时间"
              @change="
                (tableParam.startDate = startTimDateEndTimDate[0] || ''),
                  (tableParam.endDate = startTimDateEndTimDate[1] || '')
              "
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <span slot="label">执行阶段</span>
            <el-select
              v-model="tableParam.executePhase"
              placeholder="请选择"
              style="width: 400px"
            >
              <el-option label="委托交底" value="1"></el-option>
              <el-option label="评估" value="2"></el-option>
              <el-option label="投标" value="3"></el-option>
              <el-option label="合同交底" value="4"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button
          class="bottom_all_two"
          @click="
            (tableParamType = false),
              (tableParam.roadworklInkman = ''),
              (startTimDateEndTimDate = []),
              (tableParam.startDate = ''),
              (tableParam.endDate = ''),
              (tableParam.executePhase = '')
          "
          >取 消</el-button
        >
        <el-button
          class="bottom_all"
          style="margin-left: 24px"
          @click="gettableData(), (tableParamType = false)"
          >搜 索</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      v-dialogDrag
      :visible.sync="fromDate2Type"
      width="850px"
      :close-on-click-modal="false"
    >
      <span slot="title" class="dialog-title">生产处工程信息</span>
      <div class="dialoginfo">
        <el-form
          ref="fromDate2"
          :inline="true"
          :model="fromDate2"
          label-width="110px"
          hide-required-asterisk
          :rules="rules2"
          :disabled="fromDate2Disabled"
        >
          <el-form-item
            prop="name"
            :rules="[
              { required: true, message: '请输入工程名称', trigger: 'change' },
            ]"
          >
            <span slot="label" style="color: #ff0000">工程名称</span>
            <el-input
              v-model="fromDate2.name"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item
            prop="place"
            :rules="[
              { required: true, message: '请输入地理位置', trigger: 'change' },
            ]"
          >
            <span slot="label" style="color: #ff0000">地理位置</span>
            <el-input
              v-model="fromDate2.place"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item
            prop="businessTypeId"
            :rules="[
              { required: true, message: '请选择业务类型', trigger: 'change' },
            ]"
          >
            <span slot="label" style="color: #ff0000">业务类型</span>
            <el-select
              ref="businesName"
              v-model="fromDate2.businessTypeId"
              placeholder="请选择"
              @change="
                $nextTick(() => {
                  fromDate2.businesName = $refs.businesName.selectedLabel;
                })
              "
            >
              <el-option
                v-for="(item, index) in businessTypeIdList"
                :key="index"
                :label="item.itemName"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            prop="customerId"
            :rules="[
              { required: true, message: '请输入客户名称', trigger: 'change' },
            ]"
          >
            <span slot="label" style="color: #ff0000">客户名称</span>

            <el-select
              ref="customerName"
              v-model="fromDate2.customerId"
              placeholder="请选择"
              @change="
                $nextTick(() => {
                  fromDate2.customerName = $refs.customerName.selectedLabel;
                })
              "
            >
            <template v-if="fromDate2.businessTypeId == 2 || fromDate2.businessTypeId == 3">
                <el-option v-for="item,index in customerIdList" :key="index" :label="item.name" :value="item.id"> </el-option>
            </template>
            <template v-if="fromDate2.businessTypeId ==4">
                <el-option v-for="item,index in cooperationCusIdList" :key="index" :label="item.supplierName" :value="item.contractId">
                  <span>{{item.supplierName}}</span>_<span>{{item.contractNo}}</span>
                </el-option>
            </template>
            </el-select>
          </el-form-item>
          <el-form-item
            prop="expectedAmount"
            label-width="160px"
            :rules="[
              {
                required: true,
                message: '请输入预估用砼量',
                trigger: 'change',
              },
            ]"
          >
            <span slot="label" style="color: #ff0000">预估用砼量（方）</span>
            <el-input
              v-model="fromDate2.expectedAmount"
              type="Number"
              style="width: 190px"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item
            prop="expectedAmount"
            label-width="111px"
            :rules="[
              { required: true, message: '请选择供应时间', trigger: 'change' },
            ]"
          >
            <span slot="label">供应时间</span>
            <el-date-picker
              v-model="fromDate2.startTime"
              type="datetime"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd HH:mm:ss"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <span slot="label">联系人</span>
            <el-input
              v-model="fromDate2.roadworklInkman"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item prop="roadworkPhone">
            <span slot="label">电话</span>
            <el-input
              v-model="fromDate2.roadworkPhone"
              placeholder="请输入"
              type="Number"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item>
            <span slot="label">备注</span>
            <el-input
              v-model="fromDate2.remark"
              style="width: 600px"
              type="textarea"
              :rows="5"
              resize="none"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button
          class="bottom_all_two"
          @click="$refs.fromDate2.resetFields(), (fromDate2Type = false)"
          >关 闭</el-button
        >
        <el-button
          v-if="fromDate2Disabled == false"
          class="bottom_all"
          style="margin-left: 24px"
          @click="sumbit2()"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import regproject from "./components/regproject.vue";
import personProject from "@/components/ChoisePerson/personProject.vue";
import mixin from "@/mixins/ICPSmixin.js";
import {
  queryPage,
  Download,
  getExecutePhaseStatus,
  udatePrincipal,
  customerqueryPage,
  collaborateCustomers,
} from "@/api/internetSales/projectManagement.js";
import {
  saveengineeringManagement,
  QueryOneByid,
  queryAllByCompanyId,
} from "@/api/internetSales/chanceManagement.js";
import treeData from "@/views/platform/ICPS/basicConfig/address.js";
import { getDicType } from "@/api/common.js";
import { getUserInfo } from "@/utils/auth.js";
export default {
  components: {
    regproject,
    personProject,
  },
  mixins: [mixin],
  data() {
    var landlinePhone = (rule, value, callback) => {
      if (value && !this.$regExp.landlinePhoneReg(value)) {
        return callback(new Error("电话格式错误！"));
      } else {
        callback();
      }
    };
    return {
      fromDate2Disabled: false,
      treeData,
      startTimDateEndTimDate: [],
      tableParamType: false,
      /*表格增删改查及下载接口*/
      queryPage: queryPage,
      DownloadURL: Download,
      /*表单页类型，0为无树状，1为有树状，有树状在el-main加上display:flex*/
      pagesType: 0,
      /*添加表单数据*/
      executePhaselist: [
        { itemName: "委托交底", id: 1 },
        { itemName: "评估", id: 2 },
        { itemName: "投标", id: 3 },
        { itemName: "合同交底", id: 4 },
      ],
      visited: false,
      visitedata: {},
      show: false,
      fromDate: {},
      personVisible: false,
      itemData: {},
      executePhaseType: false,
      roadworkIdList: [],
      businessTypeIdList: [
        // { itemName: "", id: "1" },
        { itemName: "非市场扩展", id: "2" },
        { itemName: "自用业务", id: "3" },
        { itemName: "往来业务", id: "4" },
      ],
      typeIdList: [],
      rateOfProgressIdList: [],
      UserInfo: "",
      clientTypeIdList: [],
      TreeSelectStypeNumber: 0,
      fromDate2Type: false,
      fromDate2: {
        businessTypeId: "",
        customerId: "",
        startTime: "",
      },
      rules2: {
        roadworkPhone: [{ validator: landlinePhone, trigger: "change" }],
      },
      customerIdList: [], //生产处客户
      cooperationCusIdList: [], //往来协作客户
    };
  },
  async created() {
    this.UserInfo = await getUserInfo();
    getDicType({ code: "EngineeringNature" }).then((res) => {
      this.typeIdList = res.data.items;
    });
    getDicType({ code: "customerType" }).then((res) => {
      this.clientTypeIdList = res.data.items;
    });
    getDicType({ code: "ProjectProgress" }).then((res) => {
      this.rateOfProgressIdList = res.data.items;
    });
    this.treeData.forEach((v) => {
      v.children.map((res) => {
        res.children.forEach((res2) => {
          delete res2.children;
        });
      });
    });
    queryAllByCompanyId().then((res) => {
      this.roadworkIdList = res.data;
    });
    this.tableParam = {
      ...this.tableParam,
      isAssess: 1,
      roadworklInkman: "",
      startDate: "",
      endDate: "",
      executePhase: "",
    };
    this.gettableData();
    customerqueryPage({ page: 1, pageSize: 9999 }).then((res) => {
      this.customerIdList = res.data.data;
    });
    collaborateCustomers({ contractTypeId: "5" }).then((res) => {
      this.cooperationCusIdList = res.data;
      console.log(res, "contractTypeId：“5”");
    });
  },
  methods: {
    /*移交*/
    hanldeSure(low) {
      this.itemData = {
        id: low.id,
        principal: "",
        principalId: "",
      };
      this.personVisible = true;
    },
    closeModel() {
      this.personVisible = false;
    },
    getPerson(data) {
      this.itemData.principal = data.name;
      this.itemData.principalId = data.id;
      let arr = [];
      arr.push(this.itemData);
      udatePrincipal(arr).then((res) => {
        if (res.code === 1001) {
          this.$message.success("移交成功");
          this.gettableData();
          this.personVisible = false;
        }
      });
    },
    init() {
      /*重置数据*/
      this.tableParam.name = "";
      this.tableParam.roadwork = "";
      this.gettableData();
    },
    changeVisited(data, status, executePhaseType) {
      this.visitedata = data;
      this.visited = status;
      this.executePhaseType = executePhaseType;
      this.$refs.cz.cz();
    },
    //删除交底信息
    deleteDisclose(data) {
      var row = data;
      row.status = 0;
      saveengineeringManagement(data).then((res) => {
        if (res.code === 1001) {
          this.$message.success("操作成功");
          this.gettableData();
        }
      });
    },
    close() {
      this.visitedata = "";
      this.visited = false;
    },
    sumbit(data) {
      saveengineeringManagement(data).then((res) => {
        if (res.code === 1001) {
          this.$message.success("操作成功");
          this.visited = false;
          this.gettableData();
        }
      });
    },
    sumbit2() {
      this.$refs.fromDate2.validate((valid) => {
        if (valid) {
          if (!this.fromDate2.companyId) {
            this.fromDate2.companyId = this.UserInfo.companyId;
            this.fromDate2.companyName = this.UserInfo.companyName;
            this.fromDate2.principalId = this.UserInfo.userId;
            this.fromDate2.principal = this.UserInfo.userRealName;
          }
          this.fromDate2.dataType = 2; //1是销售，2是生产处
          console.log(JSON.parse(JSON.stringify(this.fromDate2)));
          saveengineeringManagement(this.fromDate2).then((res) => {
            if (res.code === 1001) {
              this.fromDate2Type = false;
              this.$message.success("操作成功");
              this.gettableData();
            }
          });
        }
      });
    },
    sumbit2Modify(row, type) {
      this.fromDate2Disabled = false;
      if (type) {
        this.fromDate2Disabled = type;
      }
      this.fromDate2Type = true;
      this.$data.fromDate2 = this.$options.data().fromDate2;
      QueryOneByid({ id: row.id }).then((res) => {
        this.fromDate2 = { ...this.fromDate2, ...res.data };
        if (this.fromDate2.administrativeDistricts) {
          this.fromDate2.administrativeDistricts0 = JSON.parse(
            this.fromDate2.administrativeDistricts
          );
        }
      });
    },
    fromDate2TypeTrue() {
      this.fromDate2Type = true;
      this.$nextTick(() => {
        this.$refs.fromDate2.resetFields();
        this.$data.fromDate2 = this.$options.data().fromDate2;
      });
    },
    datails(low) {
      QueryOneByid({ id: low.id }).then((res) => {
        this.fromDate = res.data;
        if (this.fromDate.administrativeDistricts) {
          this.fromDate.administrativeDistricts0 = JSON.parse(
            this.fromDate.administrativeDistricts
          )[2];
        }
        this.show = true;
      });
    },
    changstatus(low) {
      this.$confirm(
        `确定切换状态为${
          ["", "委托交底", "评估", "投标", "合同交底"][low.executePhase * 1]
        }?`,
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          cancelButtonClass: "bottom_all_two",
          confirmButtonClass: "bottom_all",
          type: "warning",
        }
      )
        .then(() => {
          getExecutePhaseStatus({
            id: low.id,
            executePhase: low.executePhase,
          }).then((res) => {
            low.executePhaseStatus = res.data;
            this.$router.push({
              name: [
                "",
                "projectClarifi",
                "projectAssess",
                "internetSalestender",
                "projectClarifi",
              ][low.executePhase * 1],
            });
          });
          this.$message({
            type: "success",
            message: "切换成功!",
          });
        })
        .catch(() => {
          this.gettableData();
        });
    },
    TreeSelectStypeFun() {
      if (this.TreeSelectStypeNumber === 0) {
        this.TreeSelectStypeNumber = 1;
        setTimeout(() => {
          const dom = document.body.lastChild;
          dom.style.zIndex = "10000";
        }, 1000);
      }
    },
    sizeChange(value) {
      this.tableParam.pageSize = value;
      this.gettableData();
    },
  },
};
</script>

<style lang="scss" scoped>
.show {
  padding: 0 !important;
  .el-input,
  .el-select {
    width: 227px;
  }
  .dialoginfo {
    padding: 0;
  }
  .form-title {
    font-size: 18px;
    margin: 10px 0;
  }
}
.el-input,
.el-select {
  width: 240px;
}
.project-name {
  font-size: 18px;
}
.accout-container {
  margin: 10px 0;
  .accout-list {
    margin: 10px 0;
  }
}
.form-title {
  font-size: 18px;
  margin: 10px 0;
}
.table_link {
  margin-left: 10px;
  color: $bg_color;
}

.table_link:hover {
  opacity: 0.8;
}
</style>
